{template 'common/header'}
{if $operation == 'display'}
<a href="{php echo $this->createWebUrl('news',array('op' =>'post'))}" class="btn btn-success"><i class="fa fa-plus"></i> 添加新闻</a>
<div class="panel panel-info" style="margin-top: 10px;">
	<div class="panel-heading">搜索</div>
	<div class="panel-body">
		<form action="./index.php" method="get" class="form-horizontal" role="form" id="form1">
			<input type="hidden" name="c" value="site" />
			<input type="hidden" name="a" value="entry" />
			<input type="hidden" name="m" value="hellozjx_mapwxapp" />
			<input type="hidden" name="do" value="news" />
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">关键字</label>
				<div class="col-sm-8 col-lg-9 col-xs-12">
					<input class="form-control" name="keyword" id="" type="text" value="{$_GPC['keyword']}" placeholder="输入新闻名称">
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
				<div class="col-sm-5 col-xs-12">
					<button class="btn btn-success"><i class="fa fa-search"></i> 搜索</button>
				</div>
			</div>
		</form>
	</div>
</div>
<div class="main panel panel-default">
	<div class="panel-body table-responsive">
		<table class="table table-hover">
			<thead class="navbar-inner">
			<tr>
				<th style="width:30px;">ID</th>
				<th style="text-align: center;">显示顺序</th>
				<th style="text-align: center;">标题</th>
				<th style="text-align: center;">创建时间</th>
				<th style="text-align: center">状态</th>
				<th style="text-align: center;">操作</th>
			</tr>
			</thead>
			<tbody>
			{loop $list $item}
			<tr>
				<td style="vertical-align: inherit;">{$item['id']}</td>
				<td style="text-align: center;vertical-align: inherit;">{if empty($item['sort'])}0{else}{$item['sort']}{/if}</td>
				<td style="text-align: center;vertical-align: inherit;">{$item['title']}</td>
				<td style="text-align: center;vertical-align: inherit;">{$item['create_time']}</td>
				<td style="text-align: center;vertical-align: inherit;">{if $item['status'] == 1}已发布{else}未发布{/if}</td>
				<td style="text-align:center;font-size: 10px;vertical-align: inherit;">
					<a href="{php echo $this->createWebUrl('news', array('op' => 'post', 'id' => $item['id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="修改"><i class="fa fa-edit"></i></a>
					<a href="{php echo $this->createWebUrl('news', array('op' => 'delete', 'id' => $item['id']))}" onclick="return confirm('确认删除吗？');return false;" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-times"></i></a>
				</td>
			</tr>
			{/loop}
			</tbody>
		</table>
		{$pager}
	</div>
</div>
{elseif $operation == 'post'}
<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit='return formcheck()'>
		<div class="panel panel-default">
			<div class="panel-heading">
				新闻信息
			</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="sort" class="form-control" value="{$news['sort']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>标题</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='title' name="title" class="form-control" value="{$news['title']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>发布教师</label>
					<div class="col-sm-9 col-xs-12">
						<select name="teacherId" id="teacherId">
							<?php foreach($teacherList as $key=>$val){ ?>
								<option value="{$val['id']}" {if $val['id'] == $news['teacher_id']}selected{/if} >{$val['name']}</option>
							<?php } ?>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>是否发布</label>
					<div class="col-sm-9 col-xs-12">
						<label class='radio-inline'>
							<input type='radio' name='status' value='1' {if $news['status']==1}checked{/if} /> 是
						</label>
						<label class='radio-inline'>
							<input type='radio' name='status' value='2' {if $news['status']==2}checked{/if} /> 否
						</label>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>详情介绍</label>
					<div class="col-sm-9 col-xs-12">
						{php echo tpl_ueditor('content', $news['content'])}
					</div>
				</div>
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="id" value="{$news['id']}" />
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
	</form>
</div>
<script language='javascript'>
	function formcheck() {
		if ($("#title").val() == '') {
			util.message("请输入标题");
			return false;
		}
		var isPublish = $("[name='status']:checked").val();
		if(isPublish== '' || isPublish == undefined){
			util.message("请选择发布状态");
			return false;
		}

		return true;
	}
</script>
{/if}

{template 'common/footer'}